<!DOCTYPE html>
<html>
<head>
    <title>打印</title>
    <meta charset="utf-8">
    <style>
        .printBox {

        }
        .button1{
            color: #fff;
            background-color: #1890ff;
            border-color: #1890ff;
            text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);
            -webkit-box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);
            box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);height: 32px;padding: 0 15px;font-size: 14px;border-radius: 4px;
            margin-left: 50%;
            margin-top: 20px;
        }
        .qrss{
            width: 30%;margin:10px 1.5%;float: left;
        }
        .qrss div{
            text-align: center;margin:10px 1.5%;width: 85%;
        }
    </style>
    <!-- 打印的样式-->
    <style media="print">
        @page {

        }
    </style>
    <script src="/jquery-3.6.0.min.js"></script>
    <script src="/dist_JsBarcode.all.min.js"></script>
    <script src="qrcode/qrcode.min.js"></script>
</head>

<body>
<!--<div class="printBox">-->

<!--</div>-->
<div id="qrcode" style=""></div>
<div style="width:1007px; ">
<!--startprint-->
<div style="font-size: 12pt;width:1007px;margin-left: 100px" id="qrcodes">

</div>
<!--endprint-->
    <input type="button" class="button1" value="打印" onclick="print_page()"></div>
</div>

<script>

    window.onload = function() {
        var qrcodes = localStorage.getItem("qrcodesPt");
        console.log(qrcodes)
        var qrInfo = JSON.parse(qrcodes);
        var qrdivs = document.getElementById("qrcodes");
        qrdivs.innerHTML="";
        qrInfo.forEach(function (n,i) {
            var qrdiv = document.createElement('div');
            var qrdiv1 = document.createElement('div');
            var qrdiv2 = document.createElement('div');
            qrdiv1.id = "qrcode"+i;
            qrdiv.classList.add("qrss") ;
            var sex = n.sex==0?'女':'男'
            qrdiv2.innerHTML=""+n.name +"/"+sex+"/"+ n.className+"/"+ n.shorter +"";
            qrdivs.appendChild(qrdiv);
            qrdiv.appendChild(qrdiv1);
            qrdiv.appendChild(qrdiv2);
            var qrcodei = new QRCode(document.getElementById("qrcode"+i), {
                width : 256,
                height : 256
            });
            qrcodei.makeCode(n.shorter);

        });

    }
    var qrcode = new QRCode(document.getElementById("qrcode"), {
        width : 100,
        height : 100
    });
    function makeCode (elText) {
        if (!elText) {
            return;
        }
        qrcode.makeCode(elText);
    }
</script>


</body>

<script type="text/javascript">
    function print_page() {
        if (!!window.ActiveXObject || "ActiveXObject" in window) { //是否ie
            remove_ie_header_and_footer();
        }
        bdhtml = window.document.body.innerHTML;
        var oldstr = document.body.innerHTML;
        sprnstr = "<!--startprint-->";
        eprnstr = "<!--endprint-->";
        prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
        prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
        // prnhtml=prnhtml.replace("999","890");
        window.document.body.innerHTML = prnhtml;
        console.log(prnhtml);
        window.print();
        document.body.innerHTML = oldstr;

    }

    function remove_ie_header_and_footer() {
        var hkey_path;
        hkey_path = "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
        try {
            var RegWsh = new ActiveXObject("WScript.Shell");
            RegWsh.RegWrite(hkey_path + "header", "");
            RegWsh.RegWrite(hkey_path + "footer", "");
        } catch (e) {
        }
    }

   /* print_page()*/
</script>
</html>
